package zsf.test.websocket.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import zsf.test.websocket.util.WebClientUtils;

@Controller
public class WebSocketController {

	//模拟用户登录
	//http://localhost:8080/clown/webSocket/index
	@RequestMapping("/index")
	public String index(HttpServletRequest request){
		
		request.getSession().setAttribute("webSocketUser", "zsf");
		return "/index";
	}

	//模拟发送信息
	@ResponseBody
	@RequestMapping(value="/send",produces = "application/json; charset=utf-8")
	public String send(){
		WebClientUtils.sendMessage("zsf", "这是测试用的");
		return "已发送";
	}
	
	
	
}
